<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  <div id="app">
    <father></father>
  </div>
  <script src="./vue.js"></script>
  <script>
    const Child = {
      template:`
        <div>
          <h2>子组件头</h2>
          <slot :msg="msg" :arr="arr" a="10"></slot>
          <h2>子组件底部</h2>
        </div>
      `,
      data() {
        return {
          msg: '子组件数据',
          arr: [1,2,3,4]
        }
      },
    }
    const Father = {
      template: `
        <div>
          <h1>这是父组件</h1>        
          <child>
            <div slot-scope="data">
              {{ data.msg }}
              <button v-for="item in data.arr" :key="item"> {{item}} </button>
            </div>  
          </child>
        </div>
      `,
      components: {
        Child
      }
    };
    Vue.component('Father', Father)
    const vm = new Vue({
      el: '#app'
    })
  </script>
</body>
</html>